<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>具名插槽的使用</title>
</head>
<body>
<div id="app">
    <cpn></cpn>
    <hr>
    <!--传入一个内容会替换掉所有插槽内容-->
    <cpn>
        <div>content</div>
    </cpn>

    <hr>
    <!--插入的内容会替换每个插槽-->
    <cpn>
        <div>content1</div>
        <div>content2</div>
        <div>content3</div>
    </cpn>
</div>

<template id="cpn">
    <h1>这是一个自定义组件</h1>
    <slot>
        <span>左边</span>
    </slot>
    <slot>
        <span>中间</span>
    </slot>
    <slot>
        <span>右边</span>
    </slot>
</template>

<script type="module">
    import {createApp, defineComponent} from "../../../js/vue.esm-browser.js";

    let component = defineComponent(
        {
            template: "#cpn",
        }
    );

    let app = createApp(
        {
            setup() {
                return {}
            }
        }
    );

    app.component("cpn", component)
    app.mount("#app")
</script>
</body>
</html>